using Cysharp.Threading.Tasks;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;

namespace YouYouFramework
{
    /// <summary>
    /// 资源加载管理器
    /// </summary>
    public class LoaderManager
    {
        #region Resource加载
        public T LoadResources<T>(string assetFullPath) where T : Object
        {
            T asset = Resources.Load<T>(assetFullPath);
            if (asset == null)
            {
                GameEntry.LogError(LogCategory.Loader, "资源加载失败==" + assetFullPath);
            }
            return asset;
        }
        public async UniTask<T> LoadResourcesAsync<T>(string assetFullPath) where T : Object
        {
            Object asset = await Resources.LoadAsync<T>(assetFullPath);
            if (asset == null)
            {
                GameEntry.LogError(LogCategory.Loader, "资源加载失败==" + assetFullPath);
            }
            return asset as T;
        }

        public T[] LoadResourcesAll<T>(string assetFullPath) where T : Object
        {
            T[] asset = Resources.LoadAll<T>(assetFullPath);
            if (asset == null)
            {
                GameEntry.LogError(LogCategory.Loader, "资源加载失败==" + assetFullPath);
            }
            return asset;
        }
        #endregion

    }
}